import React, {Component} from 'react';
import globalConText from '../context'
import B from './B'

class Child extends Component {
    render() {
        const {Consumer} = globalConText
        return (
            <div>
                <Consumer>
                    {
                        ({userName,age,changeUserName})=>{
                            return (
                                <div>
                                    <h3>Child组件</h3>
                                    <button onClick={()=>changeUserName(userName+'!!')}>点击修改userName</button>
                                    <p>userName:{userName}</p>
                                    <p>age:{age}</p>
                                </div>
                            )
                        }
                    }
                </Consumer>
                <B/>
            </div>
        );
    }
}

export default Child;